package com.cjw.controller.eventTracking;

import com.cjw.pojo.dto.database.PageDTO;
import com.cjw.pojo.dto.eventTracking.EventDTO;
import com.cjw.pojo.query.eventTracking.AddEventDTO;
import com.cjw.pojo.query.eventTracking.EventQuery;
import com.cjw.service.eventTracking.EventTrackingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api("埋点访问资源")
public class MetricsController {
    @Autowired
    private EventTrackingService eventTrackingService;

    @GetMapping("/evec/access")
    @ApiOperation("是否进行埋点")
    public Boolean access(Long id) {
        return eventTrackingService.access(id);
    }

    @PostMapping("/admin/evec/add")
    @ApiOperation("添加埋点")
    public Boolean add(@RequestBody AddEventDTO addEventDTO) {
        return eventTrackingService.add(addEventDTO);
    }

    @PostMapping("/admin/evec/delete")
    @ApiOperation("删除埋点")
    public Boolean delete(Long id) {
        return eventTrackingService.delete(id);
    }

    @PostMapping("/admin/evec/change")
    @ApiOperation("修改权限")
    public Boolean change(Long id) {
        return eventTrackingService.change(id);
    }

    @PostMapping("/admin/evec/list")
    @ApiOperation("埋点列表")
    public PageDTO<List<EventDTO>> list(@RequestBody EventQuery eventQuery) {
        return eventTrackingService.list(eventQuery);
    }
}
